package com.example.demorsa.client;

/**
 * Copyright (c) 2018-2022 ThunderSoft
 * All Rights Reserved by Thunder Software Technology Co., Ltd and its affiliates.
 * You may not use, copy, distribute, modify, transmit in any form this file
 * except in compliance with ThunderSoft in writing by applicable law.
 */

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

/**
 * @author liyuncong
 * @version 1.0
 * @file
 * @brief
 * @details
 * @date 2022-09-29
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                        NAME               DESCRIPTION
 * 2022-09-29                      liyuncong          Created
 */
//@Service
public class RestClient {

    public static class KeysInfo {

        private KeyInfo payload;

        public static class KeyInfo {
            private String publicKey;
            private String privateKey;

            public String getPublicKey() {
                return publicKey;
            }

            public void setPublicKey(String publicKey) {
                this.publicKey = publicKey;
            }

            public String getPrivateKey() {
                return privateKey;
            }

            public void setPrivateKey(String privateKey) {
                this.privateKey = privateKey;
            }
        }

        public KeyInfo getPayload() {
            return payload;
        }

        public void setPayload(KeyInfo payload) {
            this.payload = payload;
        }
    }

    //    @Autowired
    RestTemplateBuilder restTemplateBuilder;


    //@PostConstruct
    private void init() {

        final RestTemplate build = restTemplateBuilder.build();
        final ResponseEntity<KeysInfo> infos =
            build.getForEntity("http://localhost:9191/api/v1/ssh-keys", KeysInfo.class);
        System.out.println(infos);
    }
}
